home *** CD-ROM | disk | FTP | other *** search
- /* Copyright (c) 1987, 1988 Stanley T. Shebs, University of Utah. */
- /* This program may be used, copied, modified, and redistributed freely */
- /* for noncommercial purposes, so long as this notice remains intact. */
-
- #pragma comment(exestr, "@(#) map.h 12.1 95/05/09 ")
-
- /* RCS $Header: map.h,v 1.1 88/06/21 12:29:42 shebs Exp $ */
-
- /* Definitions of levels of detail in mapfiles. These values must be */
- /* ordered, so careful about fiddling with them. */
-
- #define SIDEBASIC 1
- #define SIDESLOTS 2
- #define SIDEVIEW 3
- #define SIDEMISC 4
- #define SIDEALL 9 /* guaranteed max */
-
- #define UNITBASIC 1
- #define UNITSLOTS 2
- #define UNITORDERS 3
- #define UNITALL 9 /* guaranteed max */
-
- /* These limit the junk in mapfile headers. */
-
- #define MAXINCLUDES 9 /* max number of included files */
- #define MAXMAPNOTES 40 /* max lines of notes */
-
- /* Theoretically, there is no maximum size to xconq maps, but the minimum */
- /* size is set by mystical properties of display, and is not negotiable. */
-
- #define MINWIDTH 5
- #define MINHEIGHT 5
-
- /* Letters for hex and outlined hex. Exact use is up to the interface - */
- /* the X interface has hexagonal shapes in its xconq font for these. No */
- /* problems about conflicting with unit or terrain characters. */
-
- #define HEX 'O'
- #define OHEX 'o'
-
- /* This structure should be as small as possible, since it is an */
- /* individual entry in the array containing the entire world. */
- /* The "type" and "people" slots could be combined, but this might */
- /* slow accesses undesirably, because of bit field extraction. */
-
- typedef struct a_hex {
- char type; /* terrain type at this spot */
- char people; /* alignment/number of people in this hex */
- struct a_unit *surf; /* pointer to unit if any */
- } Hex;
-
- /* Just for convenience, global variables about map live in this structure. */
-
- typedef struct a_world {
- int width, height; /* size of the world */
- int scale; /* scale in km (not really very important) */
- bool known; /* true if everybody knows what world looks like */
- Hex *terrain; /* pointer to array of hexes */
- } World;
-
- /* The type of a hex in the world is a small number representing the */
- /* terrain type. Only about 10 types are defined, in terrain.h */
-
- #ifdef SCO_UNIX
-
- #define terrain_at(x,y) ((world.terrain[windex((x),(y))]).type)
-
- #define set_terrain_at(x,y,t) \
- ((world.terrain[windex((x),(y))]).type = (t))
-
- /* The people only have a side alignment, no mention of population */
- /* (at least for now). */
-
- #define people_at(x,y) ((world.terrain[windex((x),(y))]).people)
-
- #define set_people_at(x,y,p) \
- ((world.terrain[windex((x),(y))]).people = (p))
-
- #else /* SCO_UNIX */
-
- #define terrain_at(x,y) ((world.terrain[(y)*world.width+(x)]).type)
-
- #define set_terrain_at(x,y,t) \
- ((world.terrain[(y)*world.width+(x)]).type = (t))
-
- /* The people only have a side alignment, no mention of population */
- /* (at least for now). */
-
- #define people_at(x,y) ((world.terrain[(y)*world.width+(x)]).people)
-
- #define set_people_at(x,y,p) \
- ((world.terrain[(y)*world.width+(x)]).people = (p))
-
- #endif /* SCO_UNIX */
-
- #define NOBODY 0
-
- #define unpopulated(x,y) (people_at((x),(y)) == NOBODY)
-
- /* The unit is a raw pointer - this macro is used a *lot*. (Any prospects */
- /* for optimization?) */
-
- #ifdef SCO_UNIX
-
- #define unit_at(x,y) ((world.terrain[windex((x),(y))]).surf)
-
- #define set_unit_at(x,y,u) \
- ((world.terrain[windex((x),(y))]).surf = (u))
-
- #else /* SCO_UNIX */
-
- #define unit_at(x,y) ((world.terrain[(y)*world.width+(x)]).surf)
-
- #define set_unit_at(x,y,u) \
- ((world.terrain[(y)*world.width+(x)]).surf = (u))
-
- #endif /* SCO_UNIX */
-
- /* This little macro implements wraparound in the x direction. */
- /* The stupid add is for the benefit of brain-damaged mod operators */
- /* that don't handle negative numbers properly. */
-
- #define wrap(x) (((x) + 4*world.width) % world.width)
-
- /* Constrain y to northern and southern edges. */
-
- #define limit(y) (max(0, min((y), (world.height-1))))
-
- #define interior(y) (max(1, min((y), (world.height-2))))
-
- /* Declaration of the world itself. */
-
- extern World world;
-